home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / debug / MemSniff.lha / MemSniff / MemSniff.doc < prev    next >
Text File  |  1999-01-07  |  11KB  |  312 lines

  1.                          The THOR-Software Licence (v2, 24th June 1998)
  2.  
  3.  
  4. This License applies to the computer programs known as "MemSniff" and
  5. the "MemSniff.doc". The "Program", below, refers to such program. The
  6. "Archive" refers to the package of distribution, as prepared by the author
  7. of the Program, Thomas Richter. Each licensee is addressed as "you".
  8.  
  9.  
  10.  
  11. The Program and the data in the archive are freely distributable
  12. under the restrictions stated below, but are also Copyright (c)
  13. Thomas Richter.
  14.  
  15. Distribution of the Program, the Archive and the data in the Archive by a
  16. commercial organization without written permission from the author to any
  17. third party is prohibited if any payment is made in connection with such
  18. distribution, whether directly (as in payment for a copy of the Program) or
  19. indirectly (as in payment for some service related to the Program, or
  20. payment for some product or service that includes a copy of the Program
  21. "without charge"; these are only examples, and not an exhaustive enumeration
  22. of prohibited activities).
  23.  
  24.  
  25. However, the following methods of distribution
  26. involving payment shall not in and of themselves be a violation of this
  27. restriction:
  28.  
  29.  
  30. (i) Posting the Program on a public access information storage and
  31. retrieval service for which a fee is received for retrieving information
  32. (such as an on-line service), provided that the fee is not
  33. content-dependent (i.e., the fee would be the same for retrieving the same
  34. volume of information consisting of random data).
  35.  
  36.  
  37. (ii) Distributing the Program on a CD-ROM, provided that
  38.  
  39. a) the Archive is reproduced entirely and verbatim on such CD-ROM, including
  40. especially this licence agreement;
  41.  
  42. b) the CD-ROM is made available to the public for a nominal fee only,
  43.  
  44. c) a copy of the CD is made available to the author for free except for
  45. shipment costs, and
  46.  
  47. d) provided further that all information on such CD-ROM is redistributable
  48. for non-commercial purposes without charge.
  49.  
  50.  
  51. Redistribution of a modified version of the Archive, the Program or the
  52. contents of the Archive is prohibited in any way, by any organization,
  53. regardless whether commercial or non-commercial. Everything must be kept
  54. together, in original and unmodified form.
  55.  
  56.  
  57.  
  58.  
  59. Limitations.
  60.  
  61.  
  62. THE PROGRAM IS PROVIDED TO YOU "AS IS", WITHOUT WARRANTY. THERE IS NO
  63. WARRANTY FOR THE PROGRAM, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
  64. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  65. PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE
  66. RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD
  67. THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  68. SERVICING, REPAIR OR CORRECTION.
  69.  
  70.  
  71. IF YOU DO NOT ACCEPT THIS LICENCE, YOU MUST DELETE THE PROGRAM, THE ARCHIVE
  72. AND ALL DATA OF THIS ARCHIVE FROM YOUR STORAGE SYSTEM. YOU ACCEPT THIS
  73. LICENCE BY USING OR REDISTRIBUTING THE PROGRAM.
  74.  
  75.  
  76.                                                         Thomas Richter
  77.  
  78.  
  79. _____________________________________________________________________________
  80.  
  81. Purpose of this program:
  82.  
  83. This program detects illegal memory changes by continously checking the free
  84. memory. It also protects the memory allocation functions in a mungwall like
  85. way. An exteral terminal or a interal low-level-debugger (like COP from the
  86. same author) is recommended, but not needed.
  87. MemSniff is not a Enforcer-replacement because you can't replace the full
  88. functionality of a MMU, but it does everything possible to find memory 
  89. violations.
  90.  
  91. It does not protect memory already allocated, since this is not possible 
  92. without a true MMU.
  93.  
  94. Since this memory checking is a bit tricky, there ARE KNOWN incompatibilities.
  95. DO NOT RUN MemSniff permanently, it slows down your system considerably and 
  96. reduces the size of the available memory up to the half!
  97.  
  98. Known incompatibilities:
  99.  
  100. -Does not work well with memory defraction utilities, like PoolMem from
  101. the same author.
  102. -Does not work well with the SaferPatches utility of the same author, unless
  103. you install SaferPatches with a special option.
  104. -Must be installed behind "SetPatch" and "Enforcer" and "Cyberguard", the 
  105. setup code of these programs won't work correctly with MemSniff.
  106. -Is not compatible to the P5 ppc.library.
  107.  
  108. _____________________________________________________________________________
  109.  
  110.  
  111. Theory of operation:
  112.  
  113. On memory allocation, if the memory is allocated without asking to clear it,
  114. the addresses will be filled with a non-zero bit pattern. An additional wall
  115. of memory around the allocated memory will be allocated as well, and it is
  116. watched if this wall changes. This part of the operation is similar to the
  117. well-known mungwall tool.
  118.  
  119. It keeps the names of the allocating tasks on request, to be able to check
  120. for memory holes. It remembers on request the exact # of bytes when memory 
  121. gets allocated and complains if a different size gets released.
  122.  
  123. It checks for stack overflow on request. However, this may cause unnecessary
  124. warnings with the multi-threaded FFS.
  125.  
  126. It checks for consistency of the memory lists.
  127.  
  128. It splits on request the total available memory in two parts, continously
  129. giving one half to the system and checking the other for illegal changes. 
  130. Free memory is filled with a special pattern which is checked. Thus MemSniff
  131. will find invalid memory changes in the free memory, but does neither
  132. catch changes in allocated memory nor catches reads of invalid addresses.
  133. This is not possible without a MMU or changeing the source code of the
  134. program to debug. Special debug libraries are available for this purpose 
  135. on the aminet.
  136. _____________________________________________________________________________
  137.  
  138. Installing MemSniff:
  139.  
  140. Run MemSniff in your startup-sequence, whereever you want to start the
  141. checking. It should be run AFTER the Enforcer or Cyberguard, and SetPatch.
  142.  
  143. _____________________________________________________________________________
  144.  
  145. Synopsis:
  146.  
  147. MemSniff TASK=CLIENT,PRI/N,STACK/S,CON=CONSISTENCE/S,DEBUG/S,PICKY/S,
  148.          PRE=PRESIZE/N,POST=POSTSIZE/N,FC=FILLCHAR/N,NT=NAMETAG/S,
  149.          SHOWFAIL/S,SERIAL/S,MEMLIST/S,VECTORS/S,MIN/N,MAX/N,HELP/S
  150.  
  151.  
  152. TASK:
  153. If you want to check a special task, give the name of it here. If the task 
  154. is not running, MemSniff will stop checking the memory to reduce the needed
  155. CPU time.
  156.  
  157. PRI:
  158. Priority of the checking supervisor task. This should be 0 or below, DO NOT
  159. CHOOSE HIGHER PRIORITIES WITHOUT GOOD REASON. Since the supervisor is
  160. continously running, high priorities will block other tasks from running.
  161.  
  162. STACK:
  163. Check if the stackpointer of all tasks are within the ranges given in the
  164. task structure.
  165.  
  166. Caveats:
  167. -This cannot catch short stack overflows, since not every instruction will
  168. be watched.
  169. -The filing system uses mutliple stacks for multiple threads it supports.
  170. It does not setup the stack ranges in the task structure and will cause
  171. MemSniff warnings. This is normal!
  172.  
  173.  
  174. CON:
  175. Continously check the consistency of the memory lists.
  176.  
  177.  
  178. DEBUG:
  179. Run the system debugger on failure. This will usually be the RomWack or
  180. (starting with 3.0) SAD. If you installed COP, this debugger will be started.
  181.  
  182.  
  183. PICKY:
  184. If the size given to FreeMem does not exactly match the size of AllocMem,
  185. MemSniff will be picky and complain. Usually this checking is done only up 
  186. to a multiple of eight bytes.
  187.  
  188. Caveats:
  189. The layers.library illegaly frees memory chunks in a different size than
  190. allocated. This is known to MemSniff, and it does disable the check for
  191. layers.library calls.
  192.  
  193.  
  194. PRESIZE:
  195. Specify the size of the mungwall zone prior to the allocated memory chunk.
  196. This will protect memory from illegaly modifying addresses smaller than
  197. the allocated. Defaults to 32 bytes.
  198.  
  199.  
  200. POSTSIZE:
  201. Select the size of the mungwall behind allocated memory. This will protect
  202. overflows of data into nonallocated mem.
  203.  
  204.  
  205. FILLCHAR:
  206. Specify the byte which is used to build the wall. -1, which is the default,
  207. will modify this byte from allocation to allocation.
  208.  
  209.  
  210. NAMETAG:
  211. Keep the names of all tasks that allocated memory, together with their names.
  212.  
  213. Caveats:
  214. This costs a lot of additional memory.
  215.  
  216.  
  217.  
  218. SHOWFAIL:
  219. Print warning if a memory allocation failed.
  220.  
  221.  
  222. SERIAL:
  223. Do not print MemSniff messages to the console it has been started from, but
  224. send them to a terminal connected to the serial port. The setting is
  225. 9600 baud, 8 bit, 1 stop bit, usual ascii will be used. Terminal programs
  226. are available on the net, the tiny Terminal program in the COP package
  227. will suffer, but you also need a second computer (Amiga prefered) and a null
  228. modem connector to run it.
  229.  
  230.  
  231.  
  232. MEMLIST:
  233. Print the position and size of each allocated memory block known to MemSniff,
  234. together with the name of the task it allocated. To make this working, 
  235. another copy of MemSniff must be running, and this copy must have been 
  236. started with the option NAMETAG. If an argument is supplied, only the
  237. memory allocated by this task is shown.
  238.  
  239. Caveats:
  240. This list is usally VERY LONG. It is recommended that you specify a task
  241. argument or the MIN and MAX arguments.
  242.  
  243.  
  244. MIN:
  245. Set the upper boundary (inclusive) of all memory allocations to be printed
  246. out with MEMLIST. Defaults to 0.
  247.  
  248.  
  249. MAX:
  250. Sets the upper boundary (inclusive) of the allocates to be printed. Defaults
  251. to 0xffffffff. Both MIN and MAX *must* be decimal numbers.
  252.  
  253.  
  254. TO STOP MEMSNIFF:
  255. Send a break-C signal to the memsniff task. Can be done with Ctrl-C if
  256. MemSniff has been started within a console window, or with the break
  257. command in C:. Can also be done with the COP command TASK.S
  258.  
  259.  
  260. VECTORS:
  261. Check the low memory size for spurious changes. This option is automatically
  262. disabled if an Enforcer like tool is running in the system because the
  263. enforcer is doing a better job here and MemSniff would interact.
  264.  
  265. _____________________________________________________________________________
  266.  
  267. Example calls:
  268.  
  269.  
  270. Here is how I run MemSniff in my startup-sequence:
  271.  
  272.  
  273. run <>NIL: MemSniff picky serial con nt pri=0
  274.  
  275.  
  276. This means: "Be picky about memory allocations, print debug information
  277. over the serial line, check memory lists for consistency, keep name tags
  278. of the tasks that allocated memory and set my priority to 0".
  279.  
  280. Because this runs MemSniff at a rather "high" priority, you should be 
  281. prepared to slow down your system rather dramatically.
  282.  
  283.  
  284. To print the list of allocated memory at a later time, I call MemSniff
  285. like this:
  286.  
  287. MemSniff MEMLIST
  288.  
  289.  
  290. To show only large allocations, e.g. to find programs causing huge memory
  291. holes, I'd recomment:
  292.  
  293.  
  294. MemSniff MEMLIST MIN 8192
  295.  
  296.  
  297. This prints all allocations larger than 8K.
  298.  
  299. _____________________________________________________________________________
  300.  
  301. For more fine THOR-Software programs, 
  302. "Wisit the Web" at: http://www.math.tu-berlin.de/~thor/thor/index.html
  303.  
  304.  
  305. Greetings, happy debugging,
  306.  
  307.     Thomas,        January 1999
  308.  
  309.  
  310. Warning: Debugging after 3 a.m. may cnsiderdfd trn dwn hl&/*@#
  311.  
  312.